package com.yztc.okbuy;

import android.content.Context;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.yztc.ui.category.CartgoryFragment;
import com.yztc.ui.home.HomeFragment;

public class MainActivity extends AppCompatActivity {
    private Context mContext=this;
    private FragmentManager manager;
    private FragmentTransaction transaction;
    private LinearLayout linearLayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        linearLayout= (LinearLayout) findViewById(R.id.linear);
        manager=getSupportFragmentManager();
        transaction=manager.beginTransaction();
        transaction.add(R.id.linear,new HomeFragment());
        transaction.commit();
    }

    public void clickView(View view) {
        transaction=manager.beginTransaction();
        switch (view.getId()){
            case R.id.radioButton_home:
                transaction.replace(R.id.linear,new HomeFragment());
            break;
            case R.id.radioButton_category:
                transaction.replace(R.id.linear,new CartgoryFragment());
                break;
            case R.id.radioButton_outlets:
                transaction.replace(R.id.linear,new HomeFragment());
                break;
            case R.id.radioButton_cart:
                transaction.replace(R.id.linear,new HomeFragment());
                break;
            case R.id.radioButton_mine:
                transaction.replace(R.id.linear,new HomeFragment());
                break;
        }
            transaction.commit();
    }
}
